package com.xdb.sqlparser.dialect.oracle.ast.statement;

import com.xdb.sqlparser.ast.statement.SQLSelect;
import com.xdb.sqlparser.dialect.oracle.visitor.OracleASTVisitor;
import com.xdb.sqlparser.util.SQLUtils;
import com.xdb.sqlparser.visitor.SQLAstVisitor;

public class OracleSelect extends SQLSelect {

	private OracleSelectForUpdate forUpdate;
	private OracleSelectRestriction restriction;

	public OracleSelect() {

	}

	public OracleSelectRestriction getRestriction() {
		return this.restriction;
	}

	public void setRestriction(OracleSelectRestriction restriction) {
		this.restriction = restriction;
	}

	public OracleSelectForUpdate getForUpdate() {
		return this.forUpdate;
	}

	public void setForUpdate(OracleSelectForUpdate forUpdate) {
		this.forUpdate = forUpdate;
	}

	public void output(StringBuffer buf) {
		this.query.output(buf);
		buf.append(" ");

		if (this.orderBy != null) {
			this.orderBy.output(buf);
		}
	}

	protected void accept0(SQLAstVisitor visitor) {
		accept0((OracleASTVisitor) visitor);
	}

	protected void accept0(OracleASTVisitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, this.withSubQuery);
			acceptChild(visitor, this.query);
			acceptChild(visitor, this.restriction);
			acceptChild(visitor, this.orderBy);
			acceptChild(visitor, this.forUpdate);
		}
		visitor.endVisit(this);
	}

	public String toString() {
		return SQLUtils.toOracleString(this);
	}
}
